#include <cstdio>
#include <algorithm>

using namespace std;

long long i, n, k, *arr;

int main(int argc, char const *argv[])
{
    int i;
    scanf("%d%d", &n, &k);
    arr = new long long[n];
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    nth_element(arr, arr + k, arr + n);
    printf("%d", arr[k]);
    return 0;
}
